package com.yonyou.cyxdms.sysAuth.service.service.feign;

import com.yonyou.cyx.framework.service.http.HttpRequestService;
import com.yonyou.cyx.function.bean.dto.http.RestServiceRequestDto;
import com.yonyou.cyx.function.bean.dto.http.RestServiceResponseDto;
import com.yonyou.cyxdms.sysAuth.service.constants.UserAuthConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @author liyuquan
 * @version 1.0
 * @Description
 * @since 2018/12/19 16:15：
 */
@Service
public class JDMSUserAuthClient {
    @Autowired
    HttpRequestService service;

    /**
     * 获取主应用的用户信息
     *
     * @param token 主应用的token值
     * @return org.springframework.http.ResponseEntity
     * @author zhangxianchao
     * @since 2018/9/22 0022
     */
    public RestServiceResponseDto getMainAppUserInfo(String authUrl, String token) {
        Map<String, String> requestHeaderParam = new HashMap<>();
        requestHeaderParam.put(UserAuthConstant.TOKEN_NAME_JDMS, token);

        //定义请求对象
        RestServiceRequestDto requestDto = new RestServiceRequestDto();
        requestDto.setUrl(authUrl);
        requestDto.setHeadersParams(requestHeaderParam);

        return service.getRequest(requestDto);
    }
}
